home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 72 / maccd 72.iso / updates / HTML Xtra 2.0.5 / HTML205.sit / HTML205 / xtradoc.dir / 00023_HTML-Xtra Scripts.ls < prev    next >
Encoding:
Text File  |  1999-02-22  |  4.5 KB  |  166 lines

  1. on htmlregister mem
  2. end
  3.  
  4. on htmlstartmovie
  5.   global ghtmlnormfont, ghtmlheadfont, ghtmlttfont, ghtmlfontsize, ghtmlpath, glasturl, ghtmllinkred, ghtmllinkgreen, ghtmllinkblue, ghtmlsmoothness, ghtmlmargin, gmac, gsep
  6.   htmlregister("html")
  7.   if gmac then
  8.     set ghtmlnormfont to "Times"
  9.     set ghtmlttfont to "Courier"
  10.     set ghtmlheadfont to "Helvetica"
  11.     set ghtmlfontsize to 9
  12.     set ghtmlpath to the moviePath
  13.   else
  14.     set ghtmlnormfont to "Times Roman"
  15.     set ghtmlttfont to "Courier New"
  16.     set ghtmlheadfont to "Arial"
  17.     set ghtmlfontsize to 11
  18.     set ghtmlpath to the moviePath
  19.   end if
  20.   set ghtmllinkred to 255
  21.   set ghtmllinkgreen to 0
  22.   set ghtmllinkblue to 0
  23.   set ghtmlsmoothness to 0
  24.   set ghtmlmargin to 5
  25.   htmlsetdefaults("html")
  26. end
  27.  
  28. on htmlsetdefaults mem
  29.   global ghtmlnormfont, ghtmlheadfont, ghtmlttfont, ghtmlfontsize, ghtmllinkred, ghtmllinkgreen, ghtmllinkblue, ghtmlsmoothness, ghtmlmargin
  30.   repeat with i = 1 to 7
  31.     setdefault(member mem, "NORM" & string(i), ghtmlnormfont, ghtmlfontsize + i)
  32.     setdefault(member mem, "TT" & string(i), ghtmlttfont, ghtmlfontsize + i)
  33.     if i < 7 then
  34.       setdefault(member mem, "HEAD" & string(i), ghtmlheadfont, ghtmlfontsize + 20 - (3 * i))
  35.     end if
  36.   end repeat
  37.   setlinkcolor(member mem, ghtmllinkred, ghtmllinkgreen, ghtmllinkblue)
  38.   set the scrollsmooth of member mem to ghtmlsmoothness
  39.   set the margin of member mem to ghtmlmargin
  40. end
  41.  
  42. on htmlredraw mem
  43.   set the html of member mem to the html of member mem
  44. end
  45.  
  46. on htmlclear mem
  47.   set the html of member mem to EMPTY
  48. end
  49.  
  50. on htmlload mem, File
  51.   cursor(4)
  52.   set myFile to new(xtra("FileIO"))
  53.   openFile(myFile, File, 1)
  54.   if status(myFile) then
  55.     set Source to "<HTML><BODY><P><B>Error opening file:</B><BR>" & File & "<BR><A HREF=" & QUOTE & "index.htm" & QUOTE & ">return to Table of contents.</A></P></BODY></HTML>"
  56.   else
  57.     set Source to readFile(myFile)
  58.     if status(myFile) then
  59.       alert("Error while reading from file:" & RETURN & File)
  60.       set Source to EMPTY
  61.     end if
  62.     closeFile(myFile)
  63.   end if
  64.   set myFile to VOID
  65.   set the html of member mem to Source
  66.   set Source to VOID
  67.   cursor(-1)
  68. end
  69.  
  70. on htmldolinkabs mem, URL
  71.   global glasturl, ghtmlpath
  72.   set glasturl to URL
  73.   set path to ghtmlpath & url2path(glasturl)
  74.   htmlload(mem, ghtmlpath & url2path(glasturl))
  75. end
  76.  
  77. on htmldolinkrel mem, URL
  78.   global glasturl, gmac, gsep
  79.   set URL to concaturl(glasturl, URL)
  80.   htmldolinkabs(mem, URL)
  81. end
  82.  
  83. on htmlgetmeta
  84.   global metalist
  85.   set metalist to []
  86.   set metalist to the metalist of member "html"
  87.   set metacount to count(metalist)
  88.   set str to EMPTY
  89.   if metacount then
  90.     repeat with i = 1 to metacount
  91.       if i > 1 then
  92.         set str to str & RETURN
  93.       end if
  94.       set str to str & char 1 to i of "        " & getAt(getAt(metalist, i), 1) & " (" & getAt(getAt(metalist, i), 2) & ")"
  95.     end repeat
  96.   end if
  97.   set the text of field "meta" to str
  98. end
  99.  
  100. on url2path URL
  101.   global gmac, gsep
  102.   set path to EMPTY
  103.   set olddel to the itemDelimiter
  104.   set the itemDelimiter to "/"
  105.   set cnt to the number of items in URL
  106.   repeat with i = 1 to cnt
  107.     if i > 1 then
  108.       set path to path & gsep
  109.     end if
  110.     set path to path & item i of URL
  111.   end repeat
  112.   set the itemDelimiter to olddel
  113.   return path
  114. end
  115.  
  116. on concaturl base, link
  117.   global gsep
  118.   set baselist to []
  119.   set linklist to []
  120.   set URL to EMPTY
  121.   set olddel to the itemDelimiter
  122.   set the itemDelimiter to "/"
  123.   set basecnt to the number of items in base
  124.   repeat with i = 1 to basecnt
  125.     add(baselist, item i of base)
  126.   end repeat
  127.   set linkcnt to the number of items in link
  128.   repeat with i = 1 to linkcnt
  129.     add(linklist, item i of link)
  130.   end repeat
  131.   deleteAt(baselist, basecnt)
  132.   set basecnt to count(baselist)
  133.   repeat while getAt(linklist, 1) = ".."
  134.     deleteAt(baselist, basecnt)
  135.     set basecnt to count(baselist)
  136.   end repeat
  137.   set linkcnt to count(linklist)
  138.   repeat with i = 1 to linkcnt
  139.     addAt(baselist, count(baselist) + 1, getAt(linklist, i))
  140.   end repeat
  141.   set basecnt to count(baselist)
  142.   repeat with i = 1 to basecnt
  143.     if i > 1 then
  144.       set URL to URL & the itemDelimiter
  145.     end if
  146.     set URL to URL & getAt(baselist, i)
  147.   end repeat
  148.   set the itemDelimiter to olddel
  149.   return URL
  150. end
  151.  
  152. on convertpc2url str
  153.   set olddel to the itemDelimiter
  154.   set the itemDelimiter to "\"
  155.   set anz to the number of items in str
  156.   set res to EMPTY
  157.   repeat with i = 2 to anz
  158.     if i > 2 then
  159.       set res to res & "/"
  160.     end if
  161.     set res to res & item i of str
  162.   end repeat
  163.   set the itemDelimiter to olddel
  164.   return res
  165. end
  166.